package com.atguigu.tingshu.album.client;

import com.atguigu.tingshu.album.service.TrackInfoService;
import com.atguigu.tingshu.common.annotation.login.LoginRequired;
import com.atguigu.tingshu.model.album.TrackInfo;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author Haoran Sun
 * @since 2024/08/27
 */

@RestController
@RequestMapping("client/album/trackInfo")
public class TrackClientController {

    @Resource
    private TrackInfoService trackInfoService;


    /**
     * 根据id查询声音信息
     * @param id 声音id
     * @return 声音信息
     */
    @GetMapping("/getTrackInfo/{id}")
    TrackInfo getTrackInfo(@PathVariable("id") Long id){
        return trackInfoService.getById(id);
    }

    /**
     * 根据专辑id查询声音信息
     * @param albumId 专辑id
     * @param orderNum 声音排序
     * @param trackCount 声音数量
     * @return 声音信息集合
     */
    @GetMapping("/getTrackInfoList/{albumId}/{orderNum}/{trackCount}")
    @LoginRequired
    List<TrackInfo> getTrackInfoList(@PathVariable("albumId") Long albumId,
                                     @PathVariable("orderNum")Integer orderNum,
                                     @PathVariable("trackCount")Integer trackCount){
        return trackInfoService.getTrackInfoList(albumId, orderNum, trackCount);
    }

}
